package cn.cdeden.knowledge.dubbo;

import cn.cdeden.common.core.utils.MapstructUtils;
import cn.cdeden.common.core.utils.page.TableDataInfo;
import cn.cdeden.knowledge.api.domain.page.PageQuery;
import cn.cdeden.knowledge.api.domain.vo.EnterpriseTemplateTreeVo;
import cn.cdeden.knowledge.domain.dto.EnterpriseFolderTreeDto;
import cn.cdeden.knowledge.domain.dto.EnterpriseFolderTreeQueryParam;
import cn.cdeden.knowledge.service.EnterpriseFolderTreeService;
import cn.cdeden.knowledge.api.domain.RemoteEnterpriseTemplateTreeService;
import lombok.RequiredArgsConstructor;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.stereotype.Service;

import java.util.Set;

/**
* @author GW
* @date 2023-03-27
*/
@Service
@RequiredArgsConstructor
@DubboService
public class RemoteEnterpriseTemplateTreeServiceImpl implements RemoteEnterpriseTemplateTreeService {

    // private final RedisUtils redisUtils;
    private final EnterpriseFolderTreeService enterpriseFolderTreeService;

    @Override
    public TableDataInfo<EnterpriseTemplateTreeVo> queryAll(String templateName, PageQuery pageQuery) {
        EnterpriseFolderTreeQueryParam enterpriseFolderTreeQueryParam = new EnterpriseFolderTreeQueryParam();
        enterpriseFolderTreeQueryParam.setRealName(templateName);
        TableDataInfo<EnterpriseFolderTreeDto> enterpriseFolderTreeDtoTableDataInfo = enterpriseFolderTreeService.queryAll(enterpriseFolderTreeQueryParam,pageQuery);
        return MapstructUtils.convertTableDataInfo(enterpriseFolderTreeDtoTableDataInfo, EnterpriseTemplateTreeVo.class);
    }

    @Override
    public EnterpriseTemplateTreeVo selectNext(Long id){
        EnterpriseFolderTreeDto enterpriseFolderTreeDto = enterpriseFolderTreeService.selectNext(id);
        return MapstructUtils.convert(enterpriseFolderTreeDto, EnterpriseTemplateTreeVo.class);
    }

    @Override
    public boolean deleteByTemplateId(Set<Long> ids) {
        enterpriseFolderTreeService.deleteByIds(ids);
        return true;
    }
}
